package com.gator.rabbitmq.pablo_rabbitmq.boot.rabbitmq.awesome.consumer;

import com.gator.rabbitmq.pablo_rabbitmq.boot.rabbitmq.config.TTLConfig;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @Author PABLO
 * @Date 2022/6/5 23:28
 * @Desc 延迟队列消费者(死信)
 */
@Component
@Slf4j
public class DeadQueueConsumer {

    @RabbitListener(queues = TTLConfig.DEAD_QUEUE_NAME)
    public void receive(Message message, Channel channel) {
        String msg = new String(message.getBody());
        log.info("收到延迟队列消息-->当前时间:{}-->deadQueueReceiveInfo-->{}", new Date().toString(), msg);
    }
}
